package com.ruoyi.detection.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.detection.domain.DetectionLog;
import com.ruoyi.detection.mapper.ModelMapper;
import com.ruoyi.detection.service.ModelService;
import com.ruoyi.framework.web.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Mr-Le
 */
@Service
public class ModelServiceImpl implements ModelService {

    @Autowired
    private TokenService tokenService;

    @Autowired
    private ModelMapper modelMapper;


    /**
     * 新增图片检测信息
     * @param detectionLog  对象
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertDetectionLog(DetectionLog detectionLog) {
        detectionLog.setCreateTime(DateUtils.getNowDate());
        detectionLog.setUserName(tokenService.getLoginUser(ServletUtils.getRequest()).getUsername());
        return modelMapper.insertDetectionLog(detectionLog);
    }

    @Override
    public List<DetectionLog> selectDetectionLogList(DetectionLog detectionLog) {
        return modelMapper.selectDetectionLogList(detectionLog);
    }
}
